/**
 * @version 2006-12-29
 * @author xalinx at gmail dot com
 */
package org.nanhill.commons.pattern.flow;

/**
 * Event driven FSA(finite state automaton) interface.
 * 
 * Thread safe.
 * 
 * @version 2006-12-29
 * @author xalinx at gmail dot com
 * 
 */
public interface Flow {

	/**
	 * Get this fsa id.
	 * 
	 * @return
	 */
	String getId();

	/**
	 * Add event.
	 * 
	 * @param state
	 */
	void addEvent(Event event);

	/**
	 * Add state.
	 * 
	 * @param state
	 */
	void addState(State state);

	/**
	 * Set start state.
	 * 
	 * @param startState
	 *            Atart state.
	 */
	void setStartState(State state);

	/**
	 * Get start state.
	 * 
	 * @return start state.
	 */
	State getStartState();

	/**
	 * Get state from automaton by state id.
	 * 
	 * @param stateId
	 * @return
	 */
	State getState(String stateId);

	/**
	 * Transit current State.
	 * 
	 * @param eventId
	 *            event id.
	 * 
	 */
	State transit(String eventId) throws FlowException;

}
